<?php
/**
 * beimuaihui System
 * Copyright(c) 2011-2020 beimuaihui.
 * @license    http://www.gnu.org/licenses/gpl.html     This software Under GPL V3 License 
 * beimuaihui@gmail.com
 * http://code.google.com/p/beimuaihui/
 * $Id: TranslateVar.php 262 2011-07-23 15:51:14Z beimuaihui $
 */


Zend_Loader::loadClass("Baogg_Db_Table");

class TranslateVar  extends Baogg_Db_Table {
	/**
	 * The default table name 
	 */
	protected $_name;
	protected $_db ;
	protected $_primary; 

	
	function __construct() {
		$this->_name =   'translate_var';
		$this->_myPrimary=$this->_primary= "translate_var_id";
		
		parent::__construct();
		
	}
	
	/*
	 *   get  data list
	 */
	function getList($where=array(),$order=array(),$limit=array(),$cols="*") {
	    

	    
		$select=$this->_db->select()->from(array("a"=>$this->_name),$cols)
		                            ->joinLeft(array("b"=> "translate_content"),"a.translate_var_id=b.translate_var_id and b.language_id=".BAOGG_LANGUAGE_ID,array("b.content","b.language_id"))
		                            ->joinLeft(array("c"=> "menu"),'a.menu_id=c.menu_id',array("c.menu_name","c.menu_id"));       
			
	    foreach((array)$where as $k=>$v){
	        if(is_int($v) || is_float($v)){
	           $select->where("$k =  ?",$v ) ; 
	        }else{
	           $select->where("$k like  ?",$v ) ;
	        }
	    }
	    if($order){
	       $select->order(array(" {$order['sort']} {$order['dir']} ")) ;  
	    }
		if($limit){
		    $select->limitPage($limit['start'],$limit['limit']) ;
		} 
      
     // echo $select;exit;	
     try{	  
	   $rs=$this->_db->fetchAll($select);
     }catch(Exception $e)
     {
     	echo __FILE__;
     	echo $select;
     	exit;
     }
	  // $rs[0]['sub_table']='gg';
	   
	   return $rs;	
	}

	

	function getSame($arr) {	
		$ret=array();
		
		$where['translate_var_name']=$arr['translate_var_name'];
		return parent::getSame($where);
			
	
	}
	

}
